<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
    <script src="/js/layer/layer.js"></script>

    <title>用户列表</title>
</head>
<body>
    <table>
            <tr>
                <td>id</td>
                <td>用户名</td>
                <td>密码</td>
                <td>操作</td>
            </tr>
        @foreach($user as $v)
            <tr>
                <td>{{$v->id}}</td>
                <td>{{$v->username}}</td>
                <td>{{$v->password}}</td>
                <td><a href="/index.php/User/edit/{{$v->id}}">修改</a>/<a href="javascript:;" onclick="del_func(this,{{$v->id}})">删除</a></td>
            </tr>
            @endforeach
    </table>
</body>
<style>
    table,tr,td{
        border:1px solid darkslategrey;
    }

</style>
<script>
    function del_func(obj,id){
        layer.confirm('确定要删除吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.get("/index.php/User/del/"+id,function(data){
                if(data.status == 0){
                    $(obj).parents('tr').remove();
                    layer.msg(data.message,{icon:6});
                }else{
                    layer.msg(data.message,{icon:5});
                }
            });
        }, function(){

        });
    }
</script>
</html>